<template>
  <div class="page">
    <van-nav-bar :title="userStore.user.orgname" left-text="" left-arrow @click-left="goto('/')" />
    <div class="page-box">
      <template v-if="userStore.isXianUser">
        <van-collapse v-model="activeName" accordion>
          <van-collapse-item v-for="(item, i) in xzqhData" :key="i" :title="item.text" :name="item.orgcode">
            <van-cell v-for="(cun, j) in item.nodes" :key="j" :value="cun.text" @click="setOrgnow(cun)" />
          </van-collapse-item>
        </van-collapse>
      </template>

      <template v-if="userStore.isZhenUser">
        <van-cell v-for="(cun, j) in xzqhData" :key="j" :value="cun.text" @click="setOrgnow(cun)" />
      </template>

      <template v-if="userStore.isCunUser">
        <van-cell :value="xzqhData.text" @click="setOrgnow(xzqhData)" />
      </template>
    </div>
  </div>
</template>

<script setup>
import { useXzqh } from '../../../hooks/service/useXzqh.js'
const { goto } = useGoto()
const { userStore } = useStore()

const { xzqhData, getXzqhFn, setOrgnow } = useXzqh()
const activeName = ref('')

getXzqhFn()
</script>

<style lang="scss" scoped>
p {
  word-break: break-all;
  word-break: break-word;
}

.page-box {
  box-sizing: border-box;
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
}

.van-collapse-item {
  ::v-deep(.van-cell__title) {
    font-weight: bold;
    font-size: 30px;
  }
}
</style>
